package LeetCode.leetcode704;

public class Review2 {
    public int search(int[] nums, int target) {
        int l = 0;
        int r = nums.length - 1;
        return fun(nums, target, 0, nums.length - 1);
    }

    public int fun(int[] nums, int target, int left, int right) {
        if (left > right) return -1;
        int mid = (left + right) / 2;
        if (target == nums[mid]) return mid;
        else if (target < nums[mid]) return fun(nums, target, left, mid - 1);
        else return fun(nums, target, mid + 1, right);
    }
}
